# Contributor: Dennis Krupenik <dennis@krupenik.com>
# Maintainer: Dennis Krupenik <dennis@krupenik.com>
pkgname=intel-graphics-compiler
pkgver=1.0.8744
pkgrel=0
pkgdesc="Intel® Graphics Compiler for OpenCL™"
url="https://github.com/intel/intel-graphics-compiler"
arch="x86_64"
license="MIT"
_llvm_ver="11.1.0"
depends_dev="opencl-clang-dev lld-dev~$_llvm_ver"
makedepends="$depends_dev bison cmake flex linux-headers lld-static~$_llvm_ver llvm-static~$_llvm_ver python3"
subpackages="$pkgname-dev"
source="https://github.com/intel/intel-graphics-compiler/archive/igc-$pkgver.tar.gz
	https://github.com/intel/vc-intrinsics/archive/9aafb518a05be160beffd7812a0f169c10786d04.zip
	xsi_strerror_r.patch
	remove-rtld-deepbind.patch
	"
builddir="$srcdir/$pkgname-igc-$pkgver"
options="!check" # no test suite upstream

prepare() {
	default_prepare
	mv ../vc-intrinsics-* ../vc-intrinsics
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DIGC_OPTION__FORCE_SYSTEM_LLVM=1 \
		-DIGC_PREFERRED_LLVM_VERSION=$_llvm_ver \
		-DINSTALL_SPIRVDLL=0 \
		-Wno-dev \
		$CMAKE_CROSSOPTS .
	nice make -C build
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

sha512sums="
dbbe6c08f32b80be305add570187df883aacefbf90b252c70b5705ecc7732f25873732a85558f0aed2ee8db5bcd1a59aec4d7ba110774922dbb19d4d3522a539  igc-1.0.8744.tar.gz
19b9c2926ab1c76f8ccc0bd406f1302df9250ce57dec9f5610adba15a5a1e736da6aaa51328df0c2a012db0c1b66ef9f4ee3a19ab9f54b0ecc9dfbef0d5d97ec  9aafb518a05be160beffd7812a0f169c10786d04.zip
6b1578b028140bd82c888c96e8b1d3d33b924b85657780c6214e24145d42c6965127b5faaea7a25bb0c919484ece9b9f40e714dab362ad5cf0cc064947aec694  xsi_strerror_r.patch
28c6ce539b81b5c9bf5dbe0d6ee7da31de144da4f320473bf9a190d6ba2e672001f15553248afa194414310ea5cefdf68c344bee74accdcc38ee96accf99822e  remove-rtld-deepbind.patch
"
